package com.huajx.cseek.face.server;

import com.huajx.core.handler.HandlerAdapter;
import com.huajx.core.handler.ServerHandlerFactory;
import com.huajx.core.server.annonation.MinaServer;
import com.huajx.core.server.impl.BaseTcpServer;
import com.huajx.cseek.face.handler.AddFaceHandler;
import com.huajx.util.CharsetUtil;
import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.textline.LineDelimiter;
import org.apache.mina.filter.codec.textline.TextLineCodecFactory;

/**
 * 学生人脸数据更新请求服务器
 */
@MinaServer(name = "studentFace", port = 10003)
public class StudentFaceModifyServer extends BaseTcpServer {
    @Override
    protected ServerHandlerFactory getHandler() {
        return new ServerHandlerFactory() {
            @Override
            public HandlerAdapter getHandler(Object message) {
                return new AddFaceHandler();
            }
        };
    }

    @Override
    protected ProtocolCodecFactory getProtocolCodecFactory() {
//        return new Stream
        TextLineCodecFactory codec = new TextLineCodecFactory(
                CharsetUtil.CHARSET_UTF_8,
                LineDelimiter.WINDOWS.getValue(),
                LineDelimiter.WINDOWS.getValue()
        );
        codec.setDecoderMaxLineLength(1024 * 1024 * 10);
        codec.setEncoderMaxLineLength(1024 * 1024 * 10);
        return codec;
    }


//    public static HanvonConfig config;

    @Override
    protected void initial() {
//        config = Hboot.config(HanvonConfig.class);
    }
}
